package com.lostad.app.vert.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**  
* 读取Properties文件的例子  
* File: TestProperties.java  
* User: leizhimin  
* Date: 2008-2-15 18:38:40  
*/   
public final class AppProperties {   
	final static Properties prop = new Properties(); 
    static {   
        InputStream in = Object.class.getResourceAsStream("/vertx-app.properties");   
        try {   
            prop.load(in);   
        } catch (IOException e) {   
            e.printStackTrace();   
        }   
    }   
  
    /**  
     * 私有构造方法，不需要创建对象  
     */   
    private AppProperties() {   
    }   
  
    public static String getWebDir() {   
        return  prop.getProperty("web.dir").trim();   
    }   
    public static String getValue(String key) {   
        return  prop.getProperty(key).trim();   
    } 
    public static int getValue(String key,int defaultValue) {   
    	
    	try{
    		defaultValue = Integer.parseInt( prop.getProperty(key).trim());
    	}catch (Exception e) {
    		e.printStackTrace();
		}
    	
        return defaultValue;   
    } 
    public static void main(String args[]){   
        System.out.println(getWebDir());   
    }   
} 